#include <stdio.h>
int main()
{
    int oreQuantity = 5, upperLimitOfBackpackWeight = 10;
    //输入矿石数量和背包重量上限
    scanf("%d %d", &oreQuantity, &upperLimitOfBackpackWeight);

    //循环输入每个矿石的重量
    int arr[oreQuantity];
    for (int i = 0; i < oreQuantity; i++)
    {
        scanf("%d", &arr[i]);
    }

    //将矿石重量从小到大排序
    for (int i = 0; i < oreQuantity; i++)
    {
        for (int j = 0; j < oreQuantity - i - 1; j++)
        {
            if (arr[j] > arr[j + 1])
            {
                int temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }

    int totalWeight = 0; //当前总重
    int count = 0;       //已经放进了几个矿石
    for (size_t i = 0; i < oreQuantity; i++)
    {
        int weight = arr[i];
        if (totalWeight + weight <= upperLimitOfBackpackWeight)
        {
            totalWeight += weight; //总重增加
            count++;               //又放进了一个矿石
        }
        else
        {
            break;
        }
    }
    printf("%d", count);
    return 0;
}

/*
Node *xxx(xxx *Node)
Node newhead =NULL;
Node *p;
While 
*/